# gunicorn

description "ML API Server"
author "Vik Paruchuri <vik@edx.org>"

start on runlevel [2345]
stop on runlevel [!2345]

respawn
respawn limit 3 30

env PID=/var/run/gunicorn/discern.pid
env WORKERS={{ ansible_processor_cores * 2 }}
env PORT={{ gunicorn_port }}
env LANG=en_US.UTF-8
env DJANGO_SETTINGS_MODULE={{discern_settings}}

chdir {{discern_dir}}
setuid {{discern_user}}

exec {{venv_dir}}/bin/gunicorn --preload -b 127.0.0.1:$PORT -w $WORKERS --timeout=30 --pythonpath={{discern_dir}} discern.wsgi